package Exception;

public class CirExc {
    public static void main(String[] args) {
        double s=0;
        Circles c1=new Circles(3.5);
        Circles c2=new Circles(-3.5);
        try{
            s = c1.area();
            System.out.println(s);
            s = c2.area();
            System.out.println(s);
        } catch (CircleException e){
            e.print();
        }
    }
}

class Circles{
    double r;
    public Circles(double r){
        this.r = r;
    }
    public double area() throws CircleException{
        if(this.r>=0){
            return r*r*3.14;
        }else{
            throw  new CircleException(this.r);
        }
    }
}

class CircleException extends Exception{
    double r;
    public CircleException(double r){
        super();
        this.r = r;
    }
    void print(){
        System.out.println("圆半径为"+this.r+"不合理");
    }

}